package com.naodong.shenluntiku.mvp.view.activity;

import android.os.Bundle;

import com.naodong.shenluntiku.R;
import com.naodong.shenluntiku.mvp.view.webView.SimpleTKWebViewListener;
import com.naodong.shenluntiku.mvp.view.webView.TKWebViewFragment;
import com.yatatsu.autobundle.AutoBundleField;

import me.shingohu.man.base.BaseMVPActivity;
import me.shingohu.man.di.component.AppComponent;

/**
 * Created by hujie on 17/5/24.
 */

public class WebViewActivity extends BaseMVPActivity {

    TKWebViewFragment fragment;

    @AutoBundleField
    String url;
    @AutoBundleField(required = false)
    String title;

    @Override
    protected void onCreateInit(Bundle savedInstanceState) {
        if (title != null) {
            setTitle(title);
        }
        fragment = TKWebViewFragment.getInstance();
        fragment.setTkWebViewListener(new SimpleTKWebViewListener() {
            @Override
            public void setReceiveTitle(String title) {
                setTitle(title);
            }
        });
        fragment.setUrl(url);
        loadRootFragment(R.id.container, fragment);
    }

    @Override
    protected boolean userAutoBindBundle() {
        return true;
    }

    @Override
    protected void setupActivityComponent(AppComponent appComponent) {

    }

    @Override
    protected int layoutId() {
        return R.layout.a_webview;
    }
}
